package cate.game.role.pvp.teampvp.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTeamPvp;
import cate.game.pvp.teampvp.dto.TeamPvpPlayerSimpleData;
import easy.java.dev.note.NoteField;

import java.util.Collections;

@ClientMsg(title = "搜索玩家的请求")
public class TeamPvpSearchReq implements MsgInput {
    @NoteField("玩家姓名")
    public String name;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        TeamPvpPlayerSimpleData player = game.pvp.teamPvp.searchPlayer(name);
        if (player != null) {
            cc.sendNow(new TeamPvpInviteListResp(Collections.singletonList(player)));
        } else {
            cc.sendNow(new TeamPvpInviteListResp(Collections.emptyList()));
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTeamPvp.SEARCH_NAME_REQ;
    }
}
